var WISAPI = function(){
	var timeout = 5000;
	
	function Api(url,extData){
		this.url = url;
		this.extData = extData;
	}
	Api.prototype.post = function(data,option){
		if(!option)option = {};
		if(this.extData){
			for(var k in this.extData){
				data[k] = this.extData[k];
			}
		}
		$.ajax({ 
			type:"POST",
			timeout:timeout,
			url:this.url, 
			dataType:"json",
		    data:data,
		    success: function(data){
		    	if(data.Flag == 100){
		    		if(option.success)option.success(data.Info);
		    	}else{
		    		if(option.failure)option.failure(data.FlagString);
		    	}
		    },
		    error:option.failure
		});
	}
	Api.prototype.choseDoc = function(option){
		this.post({method:"ChoseDoc",wisId:option.wisId,docId:option.docId},option);
	}
	Api.prototype.getPageInfo = function(option){
		this.post({method:"PageInfo",docId:option.docId,page:option.page},option);
	}
	Api.prototype.getHistory  = function(option){
		this.post({method:"History",wisId:option.wisId},option);
	}
	Api.prototype.getWisInfo  =  function(option){
		this.post({method:"WisInfo",wisId:option.wisId},option);
	}
	Api.prototype.getDocInfo = function(option){
		this.post({method:"DocInfo",docId:option.docId},option);
	}
	Api.prototype.syncDraw = function(option){
		this.post({method:"SyncDraw",wisId:option.wisId,content:option.body},option);
	}
	Api.prototype.syncPage = function(option){
		this.post({method:"SyncPage",wisId:option.wisId,page:option.page},option);
	}
	Api.prototype.allowDraw = function(option){
		this.post({method:"AllowDraw"},option);
	}
	return {
		New:function(url,extData){
			return new Api(url,extData);
		}
	};
}();